package day14;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

//测试集合运算
public class demo2 {
    @Test
    public void test1(){
        List<Integer> list1=
                new ArrayList<>(Arrays.asList(10,20,30,40,50,10));
        List<Integer> list2=
                new LinkedList<>(Arrays.asList(10,80,30,60,70));
        list1.retainAll(list2);
        System.out.println(list1);
    }
    @Test
    public void test2(){
        List<Integer> list1=
                new ArrayList<>(Arrays.asList(10,20,30,40,50,10));
        List<Integer> list2=
                new LinkedList<>(Arrays.asList(10,80,30,60,70));
        list1.addAll(list2);
        System.out.println(list1);
    }
    @Test
    public void test3(){
        List<Integer> list1=
                new ArrayList<>(Arrays.asList(10,20,30,40,50,10));
        List<Integer> list2=
                new LinkedList<>(Arrays.asList(10,80,30,60,70));
        list1.removeAll(list2);
        System.out.println(list1);
        //后期引用场景：求出共同好友，共同爱好，粉丝...
    }
}
